var vm=new Vue({
    el: "#knowledge",
    data: {
        List: [],//查询结果集
        pageSize: 5,//每页显示数量
        knowledge: {},//查询条件集
        Knowledge:{}//单条结果
    },
    mounted() {
        //初始化页面加载的方法
        this.selectPage(1);
        this.getPageData();
    },
    //监听对象，当对象值发生变化触发多条件查询分页方法
    watch:{
        knowledge:{
            handler(newValue, oldValue){
                console.log('我变化了',newValue,oldValue);
                this.selectPage(1);
            },
            deep: true
        }
    },
    methods: {
        //条件查询并分页
        selectPage: function (pageNum) {
            let that = this;
            axios.post("/knowledge/selectPage.do?pageNum=" + pageNum + "&pageSize=" + this.pageSize, this.knowledge).then(function (response) {
                that.List = response.data;
            })
        },
        saveData:function (i){
            this.Knowledge=this.List.list[i];
            localStorage.setItem('Knowledge',JSON.stringify(this.Knowledge));//将查询的结果存入本地缓存
        },
        //刷新页面或者从别的页面进入，提取this.Knowledge的值
        getPageData:function (){
            this.Knowledge=JSON.parse(localStorage.getItem('Knowledge'));
            if (this.Knowledge==null){
                this.Knowledge={};
            }
        }
    }


})